package com.yztc.orangeentertainment.ui.main.findfragment.findmodel;

import com.yztc.orangeentertainment.bean.findbean.HotSearchStarBean;
import com.yztc.orangeentertainment.bean.findbean.HotSearchStarDataBean;
import com.yztc.orangeentertainment.ui.main.findfragment.findutils.FindConstant;

import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by My on 2016/10/9.
 */
public class SearchStarModle implements ISearchStarModle {
    @Override
    public void LoadSearchStarData(String type, Map<String, String> map, final
    OnLoadSearchStarListener
            loadSearchStarListener) {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(FindConstant.FindPath.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        Call<HotSearchStarBean> call = retrofit.create(RetrofitService.class).getHotSearchStarAll
                (type, map);
        call.enqueue(new Callback<HotSearchStarBean>() {
            @Override
            public void onResponse(Call<HotSearchStarBean> call, Response<HotSearchStarBean>
                    response) {
                HotSearchStarBean hotSearchStarBean = response.body();
                HotSearchStarDataBean hotSearchStarDataBean = hotSearchStarBean.getData();
                loadSearchStarListener.getHotSearchStarListBeanList(hotSearchStarDataBean);
            }

            @Override
            public void onFailure(Call<HotSearchStarBean> call, Throwable t) {
                loadSearchStarListener.onFailure((Exception) t);
            }
        });
    }
}
